package com.shirley.algorithm.sort;

import java.util.Arrays;

public class BubbleSort extends SortBase {
    public static int[] sort(int[] source) {
        int[] arr = Arrays.copyOf(source, source.length);
        for (int i = 1; i <= arr.length - 1; i++) {
            for (int j = 0; j <= arr.length - 1 - i; j++) {
                if (arr[j] > arr[j + 1]) {
                    swap(arr, j, j + 1);
                }
            }

        }
        return arr;
    }

}
